package com.admin.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.admin.entity.SysDictDetailEntity;
import com.admin.service.SysDictDetailService;
import com.admin.web.PageResp;
import com.admin.web.request.DictDetailAddReq;
import com.admin.web.request.DictDetailPage;
import com.admin.web.request.DictDetailUpdateReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 字典明细管理
 */
@Api(tags = "字典明细管理")
@RestController
@RequestMapping("/sysDictDetail")
public class SysDictDetailController {
    @Resource
    private SysDictDetailService sysDictDetailService;

    @ApiOperation(value = "新增")
    @PostMapping("/add")
    @SaCheckPermission("sysDict:add")
    public void add(@RequestBody DictDetailAddReq dictDetailAddReq) {
        sysDictDetailService.save(dictDetailAddReq);
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("/delete")
    @SaCheckPermission("sysDict:delete")
    public void delete(@RequestBody @ApiParam(value = "id集合") List<String> ids) {
        sysDictDetailService.deleteByIds(ids);
    }

    @ApiOperation(value = "更新")
    @PutMapping("/update")
    @SaCheckPermission("sysDict:update")
    public void update(@RequestBody DictDetailUpdateReq dictDetailUpdateReq) {
        sysDictDetailService.updateById(dictDetailUpdateReq);
    }


    @ApiOperation(value = "查询列表数据")
    @PostMapping("/listByPage")
    @SaCheckPermission("sysDict:list")
    public PageResp<SysDictDetailEntity> findListByPage(@RequestBody DictDetailPage dictDetailPage) {
        return sysDictDetailService.listByPage(dictDetailPage);
    }

}
